<?php
header('content-type: text/html; charset=utf-8');
session_start();
include('../config.php'); 

if(!isset($_SESSION['ID']) && (!isset($_POST["userid"]) || $_POST["userid"]==""))
{
	header("Location:../login/login-error.php");
}
else if(isset($_SESSION['ID']))
{
	header("Location:../detail/index.php");
}
else
{
	LinkDataBase();
	
	$sql = "select * from member where id= '".$_POST["userid"]."' ";
	$result= mysql_query($sql);

	while($row = mysql_fetch_assoc($result))
	{
		$id = strtolower($row['id']);
		$pw = strtolower($row['password']);
	}
	
	
	if($id == strtolower($_POST['userid']) && $pw == strtolower($_POST['userpw']) && mb_strlen($pw,'utf8') == mb_strlen($_POST['userpw'],'utf8'))
	{
		if(!isset($_SESSION['ID']))
		{	
			$_SESSION['ID']=$_POST['userid'];
			header("Location:../detail/index.php");
		}			
	}
	else
	{
		header("Location:../login/login-error.php");
	}
}

?>
